package br.org.universa.sgos.entidade;

import java.util.List;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import br.org.universa.sgos.enums.NivelDeUrgenciaEnum;
import br.org.universa.sgos.enums.StatusAtividadeEnum;

@Entity
@Table(name = "REQ_REQUISICAO")
@AttributeOverrides({
    @AttributeOverride(name="id", column=@Column(name="REQ_ID")),
    @AttributeOverride(name="dataHoraAbertura", column=@Column(name="REQ_DH_ABERTURA")),
    @AttributeOverride(name="dataHoraFechamento", column=@Column(name="REQ_DH_FECHAMENTO"))
})
@AssociationOverrides({
    @AssociationOverride(name = "categoria", joinColumns = @JoinColumn(name = "REQ_CATEGORIA_ASSOCIADA", nullable = false)),
    @AssociationOverride(name = "agenteIniciador", joinColumns = @JoinColumn(name = "REQ_AGENTE_INICIADOR", nullable = false)),
    @AssociationOverride(name = "agenteResponsavel", joinColumns = @JoinColumn(name = "REQ_AGENTE_RESPONSAVEL"))
})
public class RegistroRequisicao extends Registro {

    @Column(name = "REQ_PROTOCOLO", nullable = false)
    private String protocolo;

    @Column(name = "REQ_NIVEL_URGENCIA")
    @Enumerated(EnumType.STRING)
    private NivelDeUrgenciaEnum nivelDeUrgencia;

    @Column(name = "REQ_DESCRICAO")
    private String descricao;

    @Column(name = "REQ_STATUS")
    @Enumerated(EnumType.STRING)
    private StatusAtividadeEnum status;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "requisicao")
    private List<RegistroTarefa> tarefas;

    public String getProtocolo() {
        return protocolo;
    }

    public void setProtocolo(String protocolo) {
        this.protocolo = protocolo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setNivelDeUrgencia(NivelDeUrgenciaEnum nivelDeUrgencia) {
        this.nivelDeUrgencia = nivelDeUrgencia;
    }

    public NivelDeUrgenciaEnum getNivelDeUrgencia() {
        return nivelDeUrgencia;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public StatusAtividadeEnum getStatus() {
        return status;
    }

    public void setStatus(StatusAtividadeEnum status) {
        this.status = status;
    }

    public List<RegistroTarefa> getTarefas() {
        return tarefas;
    }

    public void setTarefas(List<RegistroTarefa> tarefas) {
        this.tarefas = tarefas;
    }

}
